home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / fhard101.zip / VHCACHE.ASM < prev    next >
Assembly Source File  |  1990-07-23  |  17KB  |  678 lines

  1.  
  2.     title    Manage the VHARD FAT cache
  3.     subttl    Prologue
  4.     page    60,132
  5.  
  6. comment {
  7.  
  8. ******************************************************************************
  9.  
  10. File VHCACHE.ASM
  11.  
  12. Author:
  13.     Aaron L. Brenner
  14.  
  15.     BIX mail address albrenner
  16.     GEnie address A.BRENNER
  17.  
  18.     This program is hereby released to the public domain.
  19.  
  20. Purpose:
  21.     Provide a command-driven interface to the VHARD FAT/root dir cache.
  22.  
  23. Command syntax:
  24.     VHCACHE [? | ON | OFF | MANUAL | AUTO | FLUSH]
  25.  
  26. Parameters:
  27.     ? or INFO    Display information about the cache.
  28.     ON        Enable the cache.
  29.     OFF        Disable and remove the cache.
  30.     MANUAL        Disable auto-flush.
  31.     AUTO        Enable auto-flush.
  32.     FLUSH        Write the cache to disk.
  33.  
  34.     If no parameters, a brief usage message is displayed.
  35.  
  36. ERRORLEVEL returned:
  37.     0        The requested operation was performed successfully.
  38.     1        An error was reported by the driver.
  39.     2        Command syntax error.
  40.     3        VHARD.SYS not installed.
  41.     4        Invalid DOS version
  42.     5        Insufficient free memory
  43.  
  44. Notes:
  45.     All commands (including "?") require that VHARD.SYS be installed.
  46.  
  47. Revision history:
  48. 1.00    07/20/90    ALB    Created.
  49.  
  50. ******************************************************************************
  51.  
  52. endcomment {
  53.  
  54.     subttl    Included files
  55.     page
  56.  
  57.     include    dd_defs.inc
  58.     include    vhard.inc
  59.  
  60.     subttl    Program stack and data
  61.     page
  62.  
  63. vhcache_stack    segment    stack
  64.  
  65.     dw    128 dup (0)
  66.  
  67. vhcache_stack    ends
  68.  
  69.  
  70. vhcache_data    segment
  71.  
  72. assume    ds:vhcache_data
  73.  
  74. ax_value    dw    4c00h
  75. dx_value    dw    0
  76.  
  77. vhctl_handle    dw    0
  78. vhctl_name    db    'VHARDCTL',0
  79.  
  80. vhard_drive    db    0ffh        ; Drive assigned (FF = unavailable)
  81. vhard_ver    dw    0        ; BCD version of driver
  82. vhard_BPB    DOS_BPB <>        ; BPB for the driver (we ignore it)
  83.  
  84. cache_flags    db    0        ; Flags for the cache if installed
  85. cache_addr    dw    0, 0        ; Address of current cache
  86.  
  87. cmd_block    VH_CMD <>
  88.  
  89. cmd_keyword    db    8 dup (0)    ; The keyword on the command line
  90.  
  91. vhversion    db    'VHARD version is $'
  92. vhdrive_is    db    'VHARD is using drive letter $'
  93. cached_at    db    'Currently installed cache is at $'
  94. needs_flushing    db    'Cache needs to be FLUSHed', 13, 10, '$'
  95. auto_enabled    db    'AUTOflush is enabled', 13, 10, '$'
  96.  
  97. ;
  98. ; Error messages
  99. ;
  100. no_share    db    'SHARE.EXE must be run before AUTOflush can be'
  101.         db    ' enabled.', 13, 10, '$'
  102. bad_dos_ver    db    'Invalid DOS version for AUTOflush.', 13, 10, '$'
  103. no_memory    db    'Not enough memory', 13, 10, '$'
  104. no_cache    db    'The cache is not yet installed', 13, 10, '$'
  105. unk_err        db    'unknown error$'
  106. em1        db    'drive not read$'
  107. em2        db    'seek error$'
  108. em3        db    'general failure$'
  109. em4        db    'CRC error$'
  110. em5        db    'DMA boundary error$'
  111. em6        db    'DMA overrun$'
  112. em7        db    'sector not found$'
  113. em8        db    'diskette is write-protected$'
  114. em9        db    'address mark not found$'
  115. em10        db    'unknown BIOS command$'
  116. em11        db    'unknown VHARD command$'
  117. em12        db    'cache already installed$'
  118. em13        db    'cache not installed$'
  119. em14        db    'cache must be flushed$'
  120.  
  121. err_prefix    db    'Error: $'
  122. crlf_str    db    13, 10, '$'
  123.  
  124. error_messages    dw    unk_err
  125.         dw    em1
  126.         dw    em2
  127.         dw    em3
  128.         dw    em4
  129.         dw    em5
  130.         dw    em6
  131.         dw    em7
  132.         dw    em8
  133.         dw    em9
  134.         dw    em10
  135.         dw    em11
  136.         dw    em12
  137.         dw    em13
  138.         dw    em14
  139.  
  140.  
  141. ;
  142. ; Keywords we recognize
  143. ;
  144. kw1        db    1,'?'
  145. kw11        db    4,'INFO'
  146. kw2        db    2,'ON'
  147. kw3        db    3,'OFF'
  148. kw4        db    6,'MANUAL'
  149. kw5        db    4,'AUTO'
  150. kw6        db    5,'FLUSH'
  151.  
  152. keywords    dw    kw1, kw_info
  153.         dw    kw11, kw_info
  154.         dw    kw2, kw_on
  155.         dw    kw3, kw_off
  156.         dw    kw4, kw_manual
  157.         dw    kw5, kw_auto
  158.         dw    kw6, kw_flush
  159.         dw    0
  160.  
  161. usage_msg    db    'VHCACHE v1.00 - Public Domain Software', 13, 10
  162.         db    13, 10, 'Usage: VHPREP [? | ON | OFF | MANUAL | AUTO'
  163.         db    ' | FLUSH]', 13, 10
  164.         db    13, 10, '? or INFO     Display information on the cache'
  165.         db    13, 10, 'ON            Enable the cache'
  166.         db    13, 10, 'OFF           Disable and remove the cache'
  167.         db    13, 10, 'MANUAL        Disable auto-flush'
  168.         db    13, 10, 'AUTO          Enable auto-flush'
  169.         db    13, 10, 'FLUSH         Write the cache to disk'
  170.         db    13, 10, '$'
  171.  
  172. bad_kw        db    'Unknown keyword: "$'
  173. bad_kw2        db    '".', 13, 10, '$'
  174. no_driver    db    'VHARD.SYS must be installed', 13, 10, '$'
  175.  
  176. vhcache_data    ends
  177.  
  178.  
  179.     subttl    Start of program code
  180.     page    
  181.  
  182. vhcache_code    segment
  183.  
  184. assume    cs:vhcache_code, ds:nothing, es:nothing, ss:vhcache_stack
  185.  
  186.  
  187. start    proc
  188.  
  189.     call    initialize        ; Do program initialization
  190.  
  191. assume    ds:vhcache_data
  192.  
  193.     call    do_command        ; Do the command they want
  194.     mov    ax,ax_value        ;
  195.     mov    dx,dx_value        ;
  196.     int    21h            ;
  197.  
  198. start    endp
  199.  
  200.  
  201. ;*****************************************************************************
  202. ;
  203. ; Perform once-only program initialization.
  204. ;
  205. ;*****************************************************************************
  206. initialize    proc    near
  207.  
  208.     mov    ax,vhcache_data        ; Get our data segment
  209.     mov    es,ax            ;
  210.  
  211. assume    es:vhcache_data
  212.  
  213.     mov    si,81h            ; Point to the command tail
  214.     cld                ; Make sure of direction
  215. init_l1:
  216.     lodsb                ; Get a character
  217.     cmp    al,' '            ; Is it a blank?
  218.     je    init_l1            ; Yep - ignore it
  219.     cmp    al,9            ; Tab?
  220.     je    init_l1            ; Yes - ignore it
  221.     cmp    al,0dh            ; End of the line?
  222.     jne    init_l2            ; No - copy the keyword
  223.     push    es            ; Set DS aright
  224.     pop    ds            ;
  225.  
  226. assume    ds:vhcache_data
  227.  
  228.     mov    dx,offset usage_msg    ; Display the usage message
  229.     mov    ah,9            ;
  230.     int    21h            ;
  231.     mov    ax,4c02h        ; Pretend it's an error
  232.     int    21h            ; Exit to DOS
  233. init_l2:
  234.  
  235. assume    ds:nothing
  236.  
  237.     dec    si            ; Point back to where we stopped
  238.     mov    di,offset cmd_keyword[1]; Point to where we're copying to
  239.     mov    cx,6            ; Max we want to copy
  240. init_l3:
  241.     lodsb                ; Get the next byte
  242.     cmp    al,' '            ; Done with the command?
  243.     je    init_l5            ; Yes - stop copying
  244.     cmp    al,9            ; Done with it?
  245.     je    init_l5            ; Yes - stop copying
  246.     cmp    al,0dh            ; End of the line?
  247.     je    init_l5            ; Yes - stop copying
  248.     jcxz    init_l3            ; If the name buffer's full, ignore
  249.     cmp    al,'a'            ; Is it lower case?
  250.     jb    init_l4            ; No - use it
  251.     cmp    al,'z'            ; Is it?
  252.     ja    init_l4            ; Nope - use it
  253.     xor    al,20h            ; Make it upper case
  254. init_l4:
  255.     stosb                ; Put it in the name buffer
  256.     inc    cmd_keyword[0]        ; Count this character
  257.     dec    cx            ; Both ways
  258.     jmp    short init_l3        ; Loop back for more
  259. init_l5:
  260.     sub    al,al            ; Terminate it, too
  261.     stosb                ;
  262.     push    es            ; Swap segments so we can release our
  263.     push    ds            ;  environment
  264.     pop    es            ;
  265.     pop    ds            ;
  266.  
  267. assume    ds:vhcache_data, es:nothing
  268.  
  269.     mov    es,es:[2ch]        ; Get our environment segment
  270.     mov    ah,49h            ; Fn to release memory
  271.     int    21h            ;
  272.     push    ds            ; Lastly, set ES to our data seg
  273.     pop    es            ;
  274.  
  275. assume    es:vhcache_data
  276.  
  277.     mov    dx,offset vhctl_name    ; Try to get to the VHARDCTL device
  278.     mov    ax,3c02h        ;
  279.     int    21h            ;
  280.     jnc    init_l6            ; If we could, make sure it's a device
  281. init_err:
  282.     mov    dx,offset no_driver    ; Complain that the driver's missing
  283.     mov    ah,9            ;
  284.     int    21h            ;
  285.     mov    ax,4c03h        ; Exit with appropriate code
  286.     int    21h            ;
  287. init_l6:
  288.     mov    bx,ax            ; Get the handle for it
  289.     mov    vhctl_handle,ax        ; Save it for later use, too
  290.     mov    ax,4400h        ; Get info on the handle
  291.     int    21h            ;
  292.     test    dl,80h            ; Is this a device?
  293.     jz    init_err        ; No - just a file, so complain
  294.     mov    cmd_block.VC_cmd_code,CMD_GETDATA; Get driver info
  295.     mov    word ptr cmd_block.VC_buffer[0],offset vhard_drive
  296.     mov    word ptr cmd_block.VC_buffer[2],ds
  297.     mov    dx,offset cmd_block    ; Write it out to the driver
  298.     mov    cx,size VH_CMD        ;
  299.     mov    ax,4403h        ;
  300.     int    21h            ;
  301.     ret                ; Return to Main
  302.  
  303. initialize    endp
  304.  
  305.  
  306. ;*****************************************************************************
  307. ;
  308. ; Perform the command specified by cmd_keyword.
  309. ;
  310. ;*****************************************************************************
  311. do_command    proc    near
  312.  
  313.     sub    bx,bx            ; Start at the base of the table
  314.     mov    cx,bx            ;
  315. docm_l1:
  316.     mov    di,keywords[bx]        ; Pick up a keyword pointer
  317.     or    di,di            ; Hit the end of the table?
  318.     jnz    docm_l2            ; No - see if they match
  319.     mov    dx,offset bad_kw    ; Report an unknown keyword
  320.     mov    ah,9            ;
  321.     int    21h            ;
  322.     mov    dx,offset cmd_keyword[1]; Display the errant keyword
  323.     mov    cl,cmd_keyword[0]    ;
  324.     sub    ch,ch            ;
  325.     mov    bx,1            ;
  326.     mov    ah,40h            ;
  327.     int    21h            ;
  328.     mov    dx,offset bad_kw2    ; Finish out the message
  329.     mov    ah,9            ;
  330.     int    21h            ;
  331.     mov    ax,4c02h        ; Exit with error code
  332.     int    21h            ;
  333. docm_l2:
  334.     mov    si,offset cmd_keyword    ; Point to the keyword they entered
  335.     mov    cl,[